Repository navigation
fix(id/web): collab reconnects send the AUTH_OK refreshed token (#1463) - #3251
Conversation
initCollab kept the identity token as a by-value parameter: the AUTH_OK handler passed refreshedToken only to onTokenRefresh, so setupWebSocket onopen re-sent the init-time token on every reconnect. Add a currentToken closure as the single mutable source of truth (initialised from the param, updated by AUTH_OK, sent by onopen) and a collab-level regression test with a fake WebSocket: AUTH_OK with a new token, forced drop, second socket first frame must decode to [8, <new token>]. Test fails on the unpatched scanner path (1 failed/2 passed), passes with the fix (3/3); anonymous behaviour unchanged; no server or wire changes.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 42 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Fixes #1463 (queue task 4739, from triage task 1473).
Problem
initCollabcaptured the identity token by value: the AUTH_OK handler passedrefreshedTokenonly toonTokenRefresh, andsetupWebSocket'sonopenpacked[MSG.AUTH, token]with the init-time value — so every reconnect re-sent the original token and the refresh never reached the socket that needed it.Change (
pkgs/id/web/src/collab.tsonly)currentTokenclosure insideinitCollab— the single mutable source of truth, initialised from the param.refreshedTokenintocurrentToken(then callsonTokenRefreshas before — caller behaviour unchanged).onopenAUTH sendscurrentToken.No server changes, no wire-protocol changes, anonymous behaviour unchanged (no token at init and none via AUTH_OK → no AUTH frame).
Tests (laptop, this branch)
src/collab.test.ts(fake WebSocket): AUTH_OK with a new token → forced drop → second socket's first frame decodes to[8, <new token>]; plus no-refresh and anonymous controls. Fail-first: 1 failed / 2 passed on unpatched code; 3/3 pass with the fix.search-panel.test.tsaria-label failure, proven on main and filed as id(web): search-panel test expects aria-label 'Replace all' but implementation renders 'Replace all matches' — full web suite red on main #3243.bunx tsc --noEmit: one pre-existing error on main inimage-upload.test.ts:423, identical with and without this change, filed as id(web): tsc --noEmit red on main — image-upload.test.ts:423 Plugin<any> | null not assignable #3249; no new type errors.Need help on this PR? Tag
@codesmith-botwith what you need.